package com.spyz.P4_Partitioner_Flow_1;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

public class FlowPartitioner extends Partitioner<Text, FlowBean> {
    @Override
    public int getPartition(Text text, FlowBean flowBean, int i) {
        String phoneNum = text.toString();

        String prePhone = phoneNum.substring(0, 2);
        int partition;
        if (prePhone.equals("13")){
            partition= 1;
        }if (prePhone.equals("15")){
            partition = 2;
        } if (prePhone.equals("18")){
            partition = 3;
        }else{
            partition = 0;
        }

        return partition;
    }
}
